package security.Roles;

import java.util.Vector;

public class VectorUser extends User {
	
private String userName;

	private Vector<Group> userGroups;
	private Vector<Privilege> userPrivilege;
	private Vector<Role> userRoles;
	private AuthenticationToken userToken;	
	
	public VectorUser(String userName) {
		this.userName = userName;
		this.userGroups = new Vector<Group>();
		this.userPrivilege = new Vector<Privilege>();
		this.userRoles = new Vector<Role>();
	}
	
	public Vector<Group> getUserGroups() {
		return userGroups;
	}
	public void setUserGroups(Vector<Group> userGroups) {
		this.userGroups = userGroups;
	}
	public void addUserGroup(Group g) {
		this.userGroups.add(g);
	}	
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public Vector<Privilege> getUserPrivilege() {
		return userPrivilege;
	}
	public void setUserPrivilege(Vector<Privilege> userPrivilege) {
		this.userPrivilege = userPrivilege;
	}
	public void addUserPrivilege(Privilege p) {
		this.userPrivilege.add(p);
	}
	public Vector<Role> getUserRoles() {
		return userRoles;
	}
	public void setUserRoles(Vector<Role> userRoles) {
		this.userRoles = userRoles;
	}
	public void addUserRole(Role userRole) {
		userRoles.add(userRole);
	}	
	public void delUserRole(Role userRole) {
		userRoles.remove(userRole);
	}		
	public AuthenticationToken getUserToken() {
		return userToken;
	}
	public void setUserToken(AuthenticationToken userToken) {
		this.userToken = userToken;
	}
	
	// BEGIN:Static
	private static Vector<User> allUsers = new Vector<User>();

	
	//@Override
	public static Vector<User> getUsers() {		
		return allUsers;
	}

	//@Override
	public static boolean addUser(User user) {
		return allUsers.add(user);
	}

	//@Override
	public static boolean delUser(User user) {
		return allUsers.remove(user);
	}

	//@Override
	public static User getUserByName(String userName) {
		for (int i=0;i<allUsers.size();i++){ 
			if (allUsers.get(i).getUserName().equals(userName)) {
				return allUsers.get(i);
			}
		}
		return null;
	}

	//@Override
	public static boolean saveUser(User user) {
		// not needed
		return true;
	}
	
	// END:Static

}
